﻿using System;using ERP_RORZE_SYSTEM;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.XtraPrinting;
using DevExpress.XtraGrid.Views.Grid;
using System.Windows.Forms;

namespace ERP_RORZE_DLL.Product.Base
{
    public class clsConstantsFuction
    {
        public class ClsFuctionMachine
        {
            public const string GetAllMachine = "sp_242_Machine_GetAll";
            public const string GetAllMachineWTS = "sp_242_Machine_GetAllWTS";

            public const string GetAllLMachineWTS = "sp_242_Machine_GetAllLWTS";

            public const string GetAllMachineByID = "sp_242_Machine_GetAllByID";
            public const string Insert = "sp_242_Machine_Insert";
            public const string Delete = "sp_242_Machine_Delete";
            public const string Update = "sp_242_Machine_Update";

            public const string GetAllMachineConfig = "sp_242_DataSheet_GetAll";
            public const string InsertMachineConfig = "sp_242_DataSheet_Insert";
            public const string UpdateMachineConfig = "sp_242_DataSheet_Update";
            public const string DeleteMachineConfig = "sp_242_DataSheet_Delete";
            public const string GetAllMachineConfigByID = "sp_242_DataSheet_GetAllByID";

            public const string GetAllMachineGroup = "sp_242_MachineGroup_GetAll";
            public const string PNotFinishTimeAppend = "sp_242_PNotFinishTimeAppend";
            public const string PNotStartTimeAppend = "sp_242_PNotStartTimeAppend";
            public const string Capcalculation_Crosstab = "sp_242_Capcalculation_Crosstab";
            public const string CapcalculationCustomer_Crosstab = "sp_242_CapcalculationCustomer_Crosstab";
            public const string CapcalculationCustomer_CrosstabTN = "sp_242_CapcalculationCustomer_CrosstabTN";
            public const string Capcalculation_CrosstabTN = "sp_242_Capcalculation_CrosstabTN";
            public const string RMachineDailyTime_CrosstabAll = "sp_242_RMachineDailyTime_CrosstabAll";
        }

        public class ClsFuctionDeadlineCheck
        {
            public const string GetAll = "sp_242_DeadlineCheck_GetAll";
            public const string Insert = "sp_242_DeadlineCheck_Insert";
            public const string Delete = "sp_242_DeadlineCheck_Delete";
            public const string Update = "sp_242_DeadlineCheck_Update";
            public const string DeadlineCheck_Crosstab = "sp_242_DeadlineCheck_Crosstab";
        }

        public class ClsFuctionAnodQtyChange
        {
            public const string GetAll = "sp_242_AnodQtyChange_GetAll";
            public const string Insert = "sp_242_AnodQtyChange_Insert";
            public const string Delete = "sp_242_AnodQtyChange_Delete";
            public const string Update = "sp_242_AnodQtyChange_Update";
            public const string UpdateMOFinish = "sp_242_AnodQtyChange_UpdateMOFinish";
        }
        public class ClsFuctionBusOder
        {
            public const string GetAll = "sp_242_BusOder_GetAll";
            public const string GetAllCancel = "sp_242_BusOder_GetAllCancel";
            public const string GetAllMONoUpdate = "sp_242_BusOder_GetAllMONoUpdate";
            public const string GetBusOderNo = "sp_242_BusOder_GetBusOderNo";
            public const string Insert = "sp_242_BusOder_Insert";
            public const string Delete = "sp_242_BusOder_Delete";
            public const string Update = "sp_242_BusOder_Update";
            public const string CancelBusOder = "sp_242_BusOder_CancelBusOder";
            public const string CancelMO = "sp_242_BusOder_CancelMO";
            public const string CancelMOOption = "sp_242_BusOder_CancelMOOption";
            public const string DeadlineBusOder = "sp_242_BusOder_DeadlineBusOder";
            public const string DeadlineMO = "sp_242_BusOder_DeadlineMO";
            public const string DeadlineMOOption = "sp_242_BusOder_DeadlineMOOption";
            public const string QtyChangeBusOder = "sp_242_BusOder_QtyChangeBusOde";
            public const string UpdateMOQtyChange = "sp_242_BusOder_UpdateMOQtyChange";
            public const string UpdateMOFinish = "sp_242_BusOrder_UpdateMOFinish";
        }
        public class ClsFuctionPart
        {
            public const string GetAll = "sp_242_Part_GetAll";
            public const string Insert = "sp_242_Part_Insert";
            public const string Delete = "sp_242_Part_Delete";
            public const string Update = "sp_242_Part_Update";
        }
        public class ClsFuctionCustomer
        {
            public const string GetAll = "sp_242_Customer_GetAll";
        }
        public class ClsFuctionSupplier
        {
            public const string GetAll = "sp_242_Supplier_GetAll";
        }
        public class ClsFuctionCapCalculation
        {
            public const string GetAll = "sp_242_CapCalculation_GetAll";
            public const string Insert = "sp_242_CapCalculation_Insert";
            public const string Delete = "sp_242_CapCalculation_Delete";
            public const string Update = "sp_242_CapCalculation_Update";
        }
        public class ClsFuctionConfigure
        {
            public const string GetAll = "sp_242_Configure_GetAll";
            public const string Insert = "sp_242_Configure_Insert";
            public const string Delete = "sp_242_Configure_Delete";
            public const string Update = "sp_242_Configure_Update";
        }
        public class ClsFuctionDailyMachineTime
        {
            public const string GetAll = "sp_242_DailyMachineTime_GetAll";
            public const string Insert = "sp_242_DailyMachineTime_Insert";
            public const string Delete = "sp_242_DailyMachineTime_Delete";
            public const string Update = "sp_242_DailyMachineTime_Update";
        }

        public class ClsFuctionQuotation
        {
            public const string GetAll = "sp_242_Quotation_GetAll";
            public const string GetAllByID = "sp_242_Quotation_GetAllByID";
            public const string Insert = "sp_242_Quotation_Insert";
            public const string Delete = "sp_242_Quotation_Delete";
            public const string Update = "sp_242_Quotation_Update";
        }

        public class ClsFuctionDAnodInsp
        {
            public const string GetAll = "sp_242_DAnodInsp_GetAll";
            public const string Insert = "sp_242_DAnodInsp_Insert";
            public const string Delete = "sp_242_DAnodInsp_Delete";
            public const string Update = "sp_242_DAnodInsp_Update";
            public const string UpdateMOFinish = "sp_242_DAnodInsp_UpdateMOFinish";
        }
        public class ClsFuctionDataSheet
        {
            public const string GetAll = "sp_242_DataSheet_GetAll";
            public const string Insert = "sp_242_DataSheet_Insert";
            public const string Delete = "sp_242_DataSheet_Delete";
            public const string Update = "sp_242_DataSheet_Update";
        }
        public class ClsFuctionDBusInsp
        {
            public const string GetAll = "sp_242_DBusInsp_GetAll";
            public const string Insert = "sp_242_DBusInsp_Insert";
            public const string Delete = "sp_242_DBusInsp_Delete";
            public const string Update = "sp_242_DBusInsp_Update";
        }
        public class ClsFuctionDF3Store
        {
            public const string GetAll = "sp_242_DF3Store_GetAll";
            public const string Insert = "sp_242_DF3Store_Insert";
            public const string Delete = "sp_242_DF3Store_Delete";
            public const string Update = "sp_242_DF3Store_Update";
            public const string UpdateMOFinish = "sp_242_DF3Store_UpdateMOFinish";
        }
        public class ClsFuctionDHandInsp
        {
            public const string GetAll = "sp_242_DHandInsp_GetAll";
            public const string Insert = "sp_242_DHandInsp_Insert";
            public const string Delete = "sp_242_DHandInsp_Delete";
            public const string Update = "sp_242_DHandInsp_Update";
            public const string UpdateMOFinish = "sp_242_DHandInsp_UpdateMOFinish";
        }
        public class ClsFuctionDInspAnod
        {
            public const string GetAll = "sp_242_DInspAnod_GetAll";
            public const string Insert = "sp_242_DInspAnod_Insert";
            public const string Delete = "sp_242_DInspAnod_Delete";
            public const string Update = "sp_242_DInspAnod_Update";
            public const string UpdateMOFinish = "sp_242_DInspAnod_UpdateMOFinish";
        }
        public class ClsFuctionDInspF3
        {
            public const string GetAll = "sp_242_DInspF3_GetAll";
            public const string Insert = "sp_242_DInspF3_Insert";
            public const string Delete = "sp_242_DInspF3_Delete";
            public const string Update = "sp_242_DInspF3_Update";
            public const string UpdateMOFinish = "sp_242_DInspF3_UpdateMOFinish";
        }
        public class ClsFuctionDMachineHand
        {
            public const string GetAll = "sp_242_DMachineHand_GetAll";
            public const string Insert = "sp_242_DMachineHand_Insert";
            public const string Delete = "sp_242_DMachineHand_Delete";
            public const string Update = "sp_242_DMachineHand_Update";
            public const string UpdateMOFinish = "sp_242_DMachineHand_UpdateMOFinish";
        }
        public class ClsFuctionDMBusInsp
        {
            public const string GetAll = "sp_242_DMBusInsp_GetAll";
            public const string Insert = "sp_242_DMBusInsp_Insert";
            public const string Delete = "sp_242_DMBusInsp_Delete";
            public const string Update = "sp_242_DMBusInsp_Update";
            public const string UpdateMOFinish = "sp_242_DMBusInsp_UpdateMOFinish";
        }
        public class ClsFuctionDMHandInsp
        {
            public const string GetAll = "sp_242_DMHandInsp_GetAll";
            public const string Insert = "sp_242_DMHandInsp_Insert";
            public const string Delete = "sp_242_DMHandInsp_Delete";
            public const string Update = "sp_242_DMHandInsp_Update";
            public const string UpdateMOFinish = "sp_242_DMHandInsp_UpdateMOFinish";
        }
        public class ClsFuctionDMInspBus
        {
            public const string GetAll = "sp_242_DMInspBus_GetAll";
            public const string Insert = "sp_242_DMInspBus_Insert";
            public const string Delete = "sp_242_DMInspBus_Delete";
            public const string Update = "sp_242_DMInspBus_Update";
            public const string UpdateMOFinish = "sp_242_DMInspBus_UpdateMOFinish";
        }
        public class ClsFuctionDMInspHand
        {
            public const string GetAll = "sp_242_DMInspHand_GetAll";
            public const string Insert = "sp_242_DMInspHand_Insert";
            public const string Delete = "sp_242_DMInspHand_Delete";
            public const string Update = "sp_242_DMInspHand_Update";
            public const string UpdateMOFinish = "sp_242_DMInspHand_UpdateMOFinish";

            public const string GetMachHandMO = "sp_242_MO_GetAllPartHanding01";
            public const string GetMachHandMO02 = "sp_242_MO_GetAllPartHanding02";
            public const string GetInspHandMO = "sp_242_MO_GetAllPartHandingInspHand";
            public const string GetBusInsp = "sp_242_MO_GetAllPartHandingBusInsp";
        }
        public class ClsFuctionLaborWTS
        {

            public const string PWTSTOGAAPPEND = "PWTSTOGAAPPEND";
            public const string PWTSTOGADELETE = "PWTSTOGADELETE";

            public const string GetAll = "sp_242_LaborWTS_GetAll";
            public const string GetAllWTStoGA = "sp_242_LaborWTS_GetAllWTStoGA";
            public const string GetCheck = "sp_242_LaborWTS_CheckInput";
            public const string GetOverTimeStaff = "sp_242_LaborWTS_CheckStaff";
            public const string GetCheckStaff = "sp_242_LaborWTS_CheckStaff";
            public const string GetMOQty = "sp_242_LaborWTS_GetMOQty";
            public const string ChekMachineNG = "sp_242_LaborWTS_ChekMachineNG";
            public const string CheckMOOption = "sp_242_LaborWTS_CheckMOOption";
            public const string UpdateMOOption = "sp_242_LaborWTS_UpdateMOOption";
            public const string Insert = "sp_242_LaborWTS_Insert";
            public const string Delete = "sp_242_LaborWTS_Delete";
            public const string Update = "sp_242_LaborWTS_Update";
            public const string TranferToMachine = "PPasteWTSLaborMachine";
            public const string TranferToLabor = "PPasteWTSMachineLabor";
            public const string UpdateTranferToLabor = "PUpdateTransferedToLabor";
            public const string UpdateTranferToMachine = "PUpdateTranfferedToMachine";

            public const string JigReport = "sp_242_Jig_Report";
        }
        public class ClsFuctionMachineWTS
        {
            public const string GetAllWTStoGA = "sp_242_MachineWTS_GetAllWTStoGA";
            public const string GetAll = "sp_242_MachineWTS_GetAll";
            public const string GetAllByID = "sp_242_MachineWTS_GetAll";
            public const string Insert = "sp_242_MachineWTS_Insert";
            public const string Delete = "sp_242_MachineWTS_Delete";
            public const string Update = "sp_242_MachineWTS_Update";
            public const string UpdateMOOption = "sp_242_MOOPtion_Update";
        }
        public class ClsFuctionMaterialForm
        {
            public const string GetAll = "sp_242_MaterialForm_GetAll";
            public const string Insert = "sp_242_MaterialForm_Insert";
            public const string Delete = "sp_242_MaterialForm_Delete";
            public const string Update = "sp_242_MaterialForm_Update";
        }

        public class ClsFuctionKHChiTiet
        {
            public const string GetAll = "sp_242_KHChiTiet_GetAll";
            public const string Insert = "sp_242_KHChiTiet_Insert";
            public const string Delete = "sp_242_KHChiTiet_Delete";
            public const string Update = "sp_242_KHChiTiet_Update";
        }

        public class ClsFuctionLVL
        {
            public const string GetAll = "sp_242_Loaivl_GetAll";
            public const string Insert = "sp_242_Loaivl_Insert";
            public const string Delete = "sp_242_Loaivl_Delete";
            public const string Update = "sp_242_Loaivl_Update";
        }
        public class ClsFuctionMO
        {
            public const string GetAllByDate = "sp_242_MonthlyLaborCharge_GetAllByDate";
            public const string GetAllMachineByDate = "sp_242_MonthlyMachineCharge_GetAllByDate";
            public const string GetAll = "sp_242_MO_GetAll";
            public const string GetAll1 = "sp_242_MO_GetAllPartHanding";
            public const string GetAllMOWTS = "sp_242_MO_GetAllMOWTS";
            public const string GetAllLMOWTS = "sp_242_MO_GetAllLMOWTS";
            public const string GetAllMONo = "sp_242_MO_GetAllMONo";
            public const string Insert = "sp_242_MO_Insert";
            public const string Delete = "sp_242_MO_Delete";
            public const string Update = "sp_242_MO_Update";
            public const string UpdateMONo = "sp_242_BusOder_UpdateMONo";
            public const string MOStart = "sp_242_MO_MOStart";
            public const string GetOptionDataByMONo = "sp_242_MO_GetOptionDataByMONo";
            public const string UpdateMOFinish = "sp_242_MO_UpdateMOFinish";
            public const string GetAllVMoFactPartPrice = "sp_242_MO_GetAllVMoFactPartPrice";
            public const string GetAllNGCheck = "sp_242_MO_GetAllNGCheck";
            public const string GetAllStaffID = "sp_242_Staff_GetAll";
            public const string GetAllOptionID = "sp_242_MOOption_GetAllBuyMONo";

            public const string UpdateMOStart = "sp_242_MO_UpdateMOStart";
            public const string UpdateBusoderMOStart = "sp_242_MO_UpdateBusoderMOStart";
            public const string GetAllMOQtyStatus = "sp_242_MO_GetAllMOQtyStatus";
            public const string GetAllMOOptionStatus = "sp_242_MO_GetAllVMOOptStatus";
            public const string GetAllMOQtyChange = "sp_242_MO_GetAllMOQtyChange";
            public const string UpdateMONoMOQtyChange = "sp_242_MO_UpdateMONoMOQtyChange";
            public const string GetAllMONoMOFinish = "sp_242_MO_MOFinishMONo";
        }
        public class ClsFuctionStaff
        {
            public const string GetAll = "sp_242_Staff_GetAll";
            public const string GetAllWTSMachine = "sp_242_Staff_GetAllWTS";
        }

        public class ClsFuctionReport
        {
            public const string GetAllWTSNG = "sp_242_Report_WTSNG";
        }
        public class ClsFuctionMOgetData
        {
            public const string GetAll = "sp_242_MOgetData_GetAll";
            public const string Insert = "sp_242_MOgetData_Insert";
            public const string Delete = "sp_242_MOgetData_Delete";
            public const string Update = "sp_242_MOgetData_Update";
        }
        public class ClsFuctionMOMaterial
        {
            public const string GetAll = "sp_242_MOMaterial_GetAll";
            public const string Insert = "sp_242_MOMaterial_Insert";
            public const string Delete = "sp_242_MOMaterial_Delete";
            public const string Update = "sp_242_MOMaterial_Update";
            public const string MOMaterialAppend = "sp_242_MOMaterial_Append";
        }
        public class ClsFuctionMOOption
        {
            public const string GetAll = "sp_242_MOOption_GetAll";
            public const string Insert = "sp_242_MOOption_Insert";
            public const string Delete = "sp_242_MOOption_Delete";
            public const string Update = "sp_242_MOOption_Update";
            public const string MOOptionAdd = "sp_242_MOOptionAdd";
            public const string UpdateMOOpMOQtyChange = "sp_242_MOOption_UpdateMOOpMOQtyChange";
            public const string UpdateMOOpMOQtyChange2 = "sp_242_MOOption_UpdateMOOpMOQtyChange2";
            public const string UpdateMOFinish = "sp_242_MOOption_UpdateMOFinish";
        }
        public class ClsFuctionNGCheck
        {
            public const string GetAll = "sp_242_NGCheck_GetAll";
            public const string Insert = "sp_242_NGCheck_Insert";
            public const string Delete = "sp_242_NGCheck_Delete";
            public const string Update = "sp_242_NGCheck_Update";
        }
        public class ClsFuctionOption
        {
            public const string WTSGetAllOptionID = "sp_242_Option_WTSGetAllOptionID";
            public const string LWTSGetAllOptionID = "sp_242_Option_LWTSGetAllOptionID";
            public const string GetAll = "sp_242_Option_GetAll";
            public const string Insert = "sp_242_Option_Insert";
            public const string Delete = "sp_242_Option_Delete";
            public const string Update = "sp_242_Option_Update";
        }
        public class ClsFuctionOptionData
        {
            public const string GetAll = "sp_242_OptionData_GetAll";
            public const string GetAllOpt = "sp_242_OptionData_GetAllOptionIDByMONo";
            public const string intInputed = "sp_242_VMachineOPTStatus_GetAllByMONo";
            public const string PreOptionOK = "sp_242_VWTSCheck_GetAllByMONo";
            public const string MachineNG = "sp_242_VMNG_GetAllByMONo";
            public const string intMoQty = "sp_242_MO_GetAllMONo";
            public const string Insert = "sp_242_OptionData_Insert";
            public const string Delete = "sp_242_OptionData_Delete";
            public const string Update = "sp_242_OptionData_Update";
        }
        public class ClsFuctionORDERKH
        {
            public const string GetAll = "sp_242_ORDERKH_GetAll";
            public const string Insert = "sp_242_ORDERKH_Insert";
            public const string Delete = "sp_242_ORDERKH_Delete";
            public const string Update = "sp_242_ORDERKH_Update";
        }
        public class ClsFuctionOvertime
        {
            public const string GetAll = "sp_242_Overtime_GetAll";
            public const string Insert = "sp_242_Overtime_Insert";
            public const string Delete = "sp_242_Overtime_Delete";
            public const string Update = "sp_242_Overtime_Update";
        }
        public class ClsFuctionPartData
        {
            public const string GetAllPartMaterial = "sp_242_PartData_GetAllPartMaterial";
            public const string GetAllMaterial = "sp_242_Material_GetAll";
            public const string InsertMaterial = "sp_242_PartData_InsertMaterial";
            public const string DeleteMaterial = "sp_242_PartData_DeleteMaterial";
            public const string UpdateMaterial = "sp_242_PartData_UpdateMaterial";
            public const string GetAllJig = "sp_242_Jig_GetAll";
            
        }

        public class ClsFuctionJig
        {
            public const string GetAll = "sp_242_Jig_GetAll";
            public const string Insert = "sp_242_Jig_Insert";
            public const string Update = "sp_242_Jig_Update";
            public const string Delete = "sp_242_Jig_Delete";
        }

        public class ClsFuctionMaterial
        {
            public const string GetAllMaterialID = "sp_242_Material_GetAll";
            public const string GetAll = "sp_242_Material_GetAll";
            public const string Insert = "sp_242_Material_Insert";
            public const string Delete = "sp_242_Material_Delete";
            public const string Update = "sp_242_Material_Update";
        }
        public class ClsFuctionPCPKD
        {
            public const string GetAll = "sp_242_PCPKD_GetAll";
            public const string Insert = "sp_242_PCPKD_Insert";
            public const string Delete = "sp_242_PCPKD_Delete";
            public const string Update = "sp_242_PCPKD_Update";
        }
        public class ClsFuctionWTSTOGA
        {
            public const string GetAll = "sp_242_WTSTOGA_GetAll";
            public const string Insert = "sp_242_WTSTOGA_Insert";
            public const string Delete = "sp_242_WTSTOGA_Delete";
            public const string Update = "sp_242_WTSTOGA_Update";
        }
        public class ClsFuctionWork
        {
            public const string GetAll = "sp_242_Work_GetAll";
            public const string GetAllMWTS = "sp_242_Work_GetAllMWTS";
            public const string GetAllLWTS = "sp_242_Work_GetAllLWTS";
            public const string Insert = "sp_242_Work_Insert";
            public const string Delete = "sp_242_Work_Delete";
            public const string Update = "sp_242_Work_Update";
        }
        public class ClsFuctionMonthlyExpence
        {
            public const string GetAll = "sp_242_MonthlyExpence_GetAll";
            public const string Insert = "sp_242_MonthlyExpence_Insert";
            public const string Delete = "sp_242_MonthlyExpence_Delete";
            public const string Update = "sp_242_MonthlyExpence_Update";
        }

        public class ClsFuctionMonthlyLaborCharge
        {
            public const string GetAll = "sp_242_MonthlyExpence_GetAll";
            public const string Insert = "242_PMonthlyLaborChargeAppend";
            public const string Delete = "sp_242_MonthlyExpence_Delete";
            public const string Update = "sp_242_MonthlyExpence_Update";
        }

        public class ClsFuctionMonthlyMachineCharge
        {
            public const string GetAll = "sp_242_MonthlyExpence_GetAll";
            public const string Insert = "242_PMonthlyMachineChargeAppend";
            public const string Delete = "sp_242_MonthlyExpence_Delete";
            public const string Update = "sp_242_MonthlyExpence_Update";
        }

        public class ClsFuctionExpence
        {
            public const string GetAll = "sp_242_MonthlyExpence_GetAll";
            public const string Insert = "sp_242_Expence_Insert";
            public const string Delete = "sp_242_Expence_Delete";
            public const string Update = "sp_242_Expence_Update";
        }

        public class ClsFuctionQmachine
        {
            public const string GetAll = "sp_242_Qmachine_GetAll";
            public const string Insert = "sp_242_Qmachine_Insert";
            public const string Delete = "sp_242_Qmachine_Delete";
            public const string Update = "sp_242_Qmachine_Update";
        }

        public class ClsFuctionQMaterial
        {
            public const string GetAll = "sp_242_QMaterial_GetAll";
            public const string GetAllQCal = "sp_242_Quotation_GetAllCal";
            public const string Insert = "sp_242_QMaterial_Insert";
            public const string Delete = "sp_242_QMaterial_Delete";
            public const string Update = "sp_242_QMaterial_Update";
        }

        public class ClsFuctionMachineGroup
        {
            public const string GetAllMachineGRByID = "sp_242_MachineGroup_GetAllByID";
            public const string Insert = "sp_242_MachineGroup_Insert";
            public const string Delete = "sp_242_MachineGroup_Delete";
            public const string Update = "sp_242_MachineGroup_Update";
        }

        public static void ExportToExcel(GridView gridView, int type, bool openNow)
        {
            if (gridView == null) return;

            //First: Change gridView's property PrintSelectedRowOnly to True
            gridView.OptionsPrint.PrintSelectedRowsOnly = true;
            switch (type)
            {
                //0: Export selected rows
                case 0:
                    if (gridView.RowCount > 0)
                    {
                        try
                        {
                            bool success = false;
                            XlsxExportOptions option = new XlsxExportOptions();
                            option.ShowGridLines = true;
                            option.SheetName = gridView.ViewCaption;

                            FileDialog fileDialog = new SaveFileDialog();
                            fileDialog.Filter = "Excel 2007-2013|*.xlsx|Excel 97-2003 (*.xls)|*.xls";
                            fileDialog.FileName = gridView.ViewCaption;
                            if (fileDialog.ShowDialog() == DialogResult.OK)
                            {
                                gridView.BestFitColumns();
                                gridView.ExportToXlsx(fileDialog.FileName, option);
                                success = true;
                            }

                            if (success && openNow && MessageBox.Show("Do you want to open the file?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                System.Diagnostics.Process process = new System.Diagnostics.Process();
                                process.StartInfo.FileName = fileDialog.FileName;
                                process.StartInfo.Verb = "Open";
                                process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                                process.Start();

                            }

                        }
                        catch (Exception ex)
                        {

                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    }
                    else
                    {
                        MessageBox.Show("No data to export.", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                //1: Export all
                case 1:
                    if (gridView.RowCount > 0)
                    {
                        try
                        {
                            bool success = false;
                            XlsxExportOptions option = new XlsxExportOptions();
                            option.ShowGridLines = true;
                            option.SheetName = gridView.ViewCaption;

                            FileDialog fileDialog = new SaveFileDialog();
                            fileDialog.Filter = "Excel 2007-2013|*.xlsx|Excel 97-2003 (*.xls)|*.xls";
                            fileDialog.FileName = gridView.ViewCaption;
                            if (fileDialog.ShowDialog() == DialogResult.OK)
                            {
                                gridView.BestFitColumns();
                                gridView.SelectAll();
                                gridView.ExportToXlsx(fileDialog.FileName, option);
                                success = true;
                            }

                            if (success && openNow && MessageBox.Show("Do you want to open the file?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                System.Diagnostics.Process process = new System.Diagnostics.Process();
                                process.StartInfo.FileName = fileDialog.FileName;
                                process.StartInfo.Verb = "Open";
                                process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                                process.Start();

                            }
                        }
                        catch (Exception ex)
                        {

                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    }
                    else
                    {
                        MessageBox.Show("No data to export.", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                default:
                    break;
            }

        }


    }
}
